﻿using DevExpress.XtraGrid.Demos.util;
using DevExpress.XtraReports.UI;
using DXApplicationTangche.report;
using DXApplicationTangche.UC.订单一览新.销售确认单;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.流程
{
    public partial class Form销售日记账视图一览 : DevExpress.XtraEditors.XtraForm
    {
        private List<ViewSaleInfoDTO> viewSaleInfoDTOs = new List<ViewSaleInfoDTO>();
        private CustomerSaleOrderReportDTO customerSaleOrderReportDTO = new CustomerSaleOrderReportDTO();
        private SaleOrderReportDTO saleOrderReportDTO = new SaleOrderReportDTO();

        public Form销售日记账视图一览()
        {
            InitializeComponent();
            this.viewSaleInfoDTOs = 销售确认Service.getRecentViewSaleInfo();
            this.gridControl销售日记账视图一览.DataSource = this.viewSaleInfoDTOs;
            this.bandedGridView销售日记账视图一览.ExpandAllGroups();
        }

        private void 客户销售凭证ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String saleId =
                FunctionHelper.GetbandedgridViewValue(this.bandedGridView销售日记账视图一览, this.bandedGridView销售日记账视图一览.FocusedRowHandle, "id");
            this.customerSaleOrderReportDTO = 销售确认Service.getViewSaleInfoDaoByMobile(saleId);
            XtraReport销售订单 report = new XtraReport销售订单(customerSaleOrderReportDTO);
            report.DataSource = this.customerSaleOrderReportDTO.customerSaleOrderReportDetailDTOList;
            ReportPrintTool tool = new ReportPrintTool(report);
            tool.ShowPreview();
        }

        private void 销售二联凭证ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String saleId =
                FunctionHelper.GetbandedgridViewValue(this.bandedGridView销售日记账视图一览, this.bandedGridView销售日记账视图一览.FocusedRowHandle, "id");
            this.saleOrderReportDTO = 销售确认Service.getSaleOrderReportDTOByMobile(saleId);
            XtraReport销售二联凭证 report = new XtraReport销售二联凭证(saleOrderReportDTO);
            report.DataSource = this.saleOrderReportDTO.saleOrderReportDetailDTOS;
            ReportPrintTool tool = new ReportPrintTool(report);
            tool.ShowPreview();
        }
    }
}
